<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <?php
    /**
     * Created by PhpStorm.
     * User: Mak
     * Date: 2016/1/29
     * Time: 15:28
     */
    session_start();
    include "Snoopy.class.php";
    $sn=new Snoopy;

    $url="http://jw.gxsdxy.cn/jiaowures/Login.aspx";

    $post['__VIEWSTATE']=$_POST['__VIEWSTATE'];
    $post['__EVENTVALIDATION']=$_POST['__EVENTVALIDATION'];
    $post['Account']=$_POST['Account'];
    $post['PWD']=$_POST['PWD'];
    $post['CheckCode']=$_POST['CheckCode'];
    $post['cmdok']="";

    $_SESSION["stuid"]=$post['Account'];

    $verifyjpg=$_POST['img'];
    unlink("tmp\\{$verifyjpg}.jpg");

    $sn->cookies['ASP.NET_SessionId']=$_POST['Cookie'];
//    print_r($_POST['Cookie']);
    $sn->agent="Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko";
    $sn->referer="http://jw.gxsdxy.cn/jiaowures/";
    $sn->rawheaders['X_FORWARDED_FOR'] = "jw.gxsdxy.cn";
    $sn->rawheaders['Pragma']='no-cache';

    $sn->submit($url,$post);
    $c=$sn->cookies;
//    print_r($c);
    $_SESSION['cookies']=$c;

    $sn2 = new Snoopy();
    $sn2->cookies=$c;
    $sn2->agent = "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko";
    $sn2->referer = "http://jw.gxsdxy.cn/jiaowures/";
    $sn2->rawheaders['Pragma'] = 'no-cache';
    $sn2->rawheaders['X_FORWARDED_FOR'] = "jw.gxsdxy.cn";
//        $sn->fetch("http://jw.gxsdxy.cn/jiaowures/JWXS/Default.aspx");
    $sn2->maxredirs=0;
    if($sn2->fetch("http://jw.gxsdxy.cn/jiaowures/JWXS/Default.aspx")){
        if($sn2->status==200){
            echo "<script type='text/javascript'>
                   location.href='jw.php';
                  </script>";
            $_SESSION['V']=1;
        }else{
               echo "<script type='text/javascript'>
                   alert('登录失败，请重新登录！');
                   location.href='index.php';
                  </script>";
        }

    }else{
        echo "网络错误，稍后再登录。或联系敏捷软件协会，微信公众号：mjrjxh".$sn2->error;
    }


//    $sn->fetch("http://jw.gxsdxy.cn/jiaowu/JWXS/cjcx/jwxs_cjcx_like.aspx?usermain=x{$post['Account']}");
//    echo mb_convert_encoding($sn->results,"utf-8","gb2312");

    ?>
</body>
</html>
